
var str = `<form class="layui-form add-form" action="" style="margin: 30px; margin-left: 0px;" id="add_form">
<div class="layui-form-item">
  <label class="layui-form-label">类别名称</label>
  <div class="layui-input-block">
    <input type="text" name="name" required lay-verify="required|ctname" placeholder="请输入标题" autocomplete="off" class="layui-input">
  </div>
</div>
<div class="layui-form-item">
  <label class="layui-form-label">类别别名</label>
  <div class="layui-input-block">
    <input type="text" name="alias" required lay-verify="required|aliname" placeholder="请输入标题" autocomplete="off" class="layui-input">
  </div>
</div>
<div class="layui-form-item">
  <div class="layui-input-block">
    <button class="layui-btn" lay-submit lay-filter="formDemo">确认添加</button>
    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  </div>
</div>
</form>`

$('.add').on('click', function () {

    layer.open({
        type: 1,
        title: '新建类别',
        area: ['500px', '300px'],
        content: str, //这里content是一个普通的String,
        success: function () {
            $('.layui-form').on('submit', function (e) {
                e.preventDefault();
                addCate($('.layui-form').serialize(), function (res) {
                    console.log(res);
                });
            })
        }
    });


})